<template>
  <template v-if="user">
    <van-cell title="本尊名号" :value="user?.username"/>
    <van-cell title="修真录" is-link to="/user/update"/>
    <van-cell title="自创仙盟" is-link to="/user/team/create"/>
    <van-cell title="仙盟盟籍" is-link to="/user/team/join"/>
    <van-cell title="离尘归隐"  @click="Logout" />
  </template>
</template>

<script setup lang="ts">
// import {useRouter} from "vue-router";
import {onMounted, ref} from "vue";
import {getCurrentUser} from "../../services/user.ts";
import {setCurrentUserState} from "../../states/user.ts";
import {useRouter} from "vue-router";

const user = ref();

onMounted(async () => {
  user.value = await getCurrentUser();
})

const router = useRouter();

// const toEdit = (editKey: string, editName: string, currentValue: string) => {
//   router.push({
//     path: '/user/edit',
//     query: {
//       editKey,
//       editName,
//       currentValue,
//     }
//   })
// }

const Logout = async () => {
  const  s= null;
  // @ts-ignore
  setCurrentUserState(s)
  router.replace({
    path: '/',
    replace: true,
  })
}
</script>

<style scoped>

</style>